<template>
  <div v-for="data in dataInit.data">
    <el-check-tag  @change="onChange(data.id)">{{data.name}}</el-check-tag>
  </div>
</template>

<script setup>
  import { defineProps ,onMounted} from 'vue'
  import { useRouter } from 'vue-router'

  let props = defineProps({
    cardData:{                            // 父组件v-model绑定的值
      type:Object,
    },
    cardType:{
      type: String,
    },
    useStatus:{
      type: String,
    }
  });

  const dataInit=reactive({
    data:[]
  });

  const router  = useRouter();

  const initData=()=>{
    if(props.cardData!=null){
      props.cardData.forEach(c=>{
        if(c.status==props.useStatus){
          dataInit.data.push(c)
        }
      })
    }
  }

  const onChange = (id) => {
    if(props.cardType=='project'){
      router.push({
        path: '/itemKanban',
        query: {
          projectId: id,
        }
      })
    }
    console.log(id)
  }

  onMounted(()=>{
    initData()
  })
</script>
